<?php
class Tool_corpus{

  public static function get_corpus_dir($_path_dir){
    $corpus = new Corpus($_path_dir);
    $all_path = Tool_dir::get_files($_path_dir);

    foreach($all_path as $path){
      $document = new Document();
      $document->init($path);
      $corpus->push_document($document);
    }
    return $corpus;
  }

  public static function get_corpus_regexp($_dir,$_regexp){
    $id_corpus = "$_dir + $_regexp";
    $corpus = new Corpus($id_corpus);
    $all_path = Tool_dir::get_files_regexp($_dir,$_regexp);

    foreach($all_path as $path){
      $document = new Document();
      $document->init($path);
      $corpus->push_document($document);
    }
    return $corpus;
  }

/*
  public static function mtg_get_all_ids($_dir){
    return self::get_all_ids($_dir,'/[^_\/]+_/');
  }

  public static function europa_get_all_ids($_dir){
    return self::get_all_ids($_dir,'/celex_IP-[0-9]+-[0-9]+./');
  }

  public static function get_all_ids($_dir,$_rule_id){
    return Tool_dir::get_all_ids($_dir,$_rule_id);
  }

 public static function get_unified_europa($_dir,$_array_lg){
  $array_ids = self::europa_get_all_ids($_dir);
  $cpt_multidoc = 0;
  $multidoc_lg = $array_lg = array();
  foreach($array_ids as $id_europa){
    $corpus = self::get_corpus_regexp($_dir,$id_europa);
    $array_doc = $corpus->__get_array_doc();
    ++$cpt_multidoc;
    foreach($array_doc as $document){
      $id_doc = mb_strcut($document->__get_id(),-6,2);
      $multidoc_lg[$id_europa][$id_doc] = 1;
      ++$array_lg[$id_doc];
    }
  }

  $res = array();
  foreach($multidoc_lg as $multi=>$array_lg){
    $flag = true;
    foreach($_array_lg as $lg){
      if(!array_key_exists($lg,$array_lg)){
        $flag = false;
        break;
      }
    }
    if($flag){
      $res[] = $multi;
    }
  }
  return $res;
 }
*/ 
}

?>
